import Vue from 'vue'
import Element from 'element-ui'
import App from '@/App'
import i18n from '@/i18n'
import router from '@/router'
import store from '@/store'
import '@/icons'
import '@/element-ui/theme/index.css'
import '@/assets/scss/aui.scss'
import http from '@/utils/request'
import CryptoJS from "@/utils/cryptoJs";//加密
import cropperDlg from "@/components/cropperDlg";//图片裁剪
import renRadioGroup from '@/components/ren-radio-group'
import renSelect from '@/components/ren-select'
import RenCheckboxGroup from '@/components/ren-checkBox-group'
import renProcessMultiple from '@/components/ren-process-multiple'
import renProcessStart from '@/components/ren-process-start'
import renProcessRunning from '@/components/ren-process-running'
import renProcessDetail from '@/components/ren-process-detail'
import renDeptTree from '@/components/ren-dept-tree'
import renRegionTree from '@/components/ren-region-tree'
import SelectComponent from '@/components/select-component'
import { hasPermission, getDictLabel } from '@/utils'
import cloneDeep from 'lodash/cloneDeep'
// 将自动注册所有组件为全局组件
import dataV from '@jiaminghi/data-view'

Vue.use(dataV)

import Tinymce from '@/components/tinymce/index.vue'
Vue.component('tinymce', Tinymce)

import '@/utils/form-generator/styles/index.scss'
import SvgIcon from '@/utils/form-generator/components/SvgIcon'
Vue.component('svg-icon', SvgIcon)
Vue.component('cropperDlg', cropperDlg)
import 'xe-utils'
import VXETable from 'vxe-table'
import 'vxe-table/lib/index.css'
import {isMobile,isIdCard} from './utils/validate'
import formValidate from './utils/form-validate'

import '../src/assets/fonts/font.css'
//图片裁剪
import VueCropper from 'vue-cropper'
Vue.use(VueCropper)
Date.prototype.format = function (fmt) {
  var o = {
    "M+": this.getMonth() + 1,                 //月份 
    "d+": this.getDate(),                    //日 
    "h+": this.getHours(),                   //小时 
    "m+": this.getMinutes(),                 //分 
    "s+": this.getSeconds(),                 //秒 
    "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
    "S": this.getMilliseconds()             //毫秒 
  };
  if (/(y+)/.test(fmt)) {
    fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  }
  for (var k in o) {
    if (new RegExp("(" + k + ")").test(fmt)) {
      fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    }
  }
  return fmt;
}

Vue.use(VXETable)
Vue.config.productionTip = false

Vue.use(renRadioGroup)
Vue.use(renSelect)
Vue.use(RenCheckboxGroup)
Vue.use(renDeptTree)
Vue.use(renRegionTree)
Vue.use(SelectComponent)
Vue.use(renProcessMultiple)
Vue.use(renProcessStart)
Vue.use(renProcessRunning)
Vue.use(renProcessDetail)

Vue.use(Element, {
  size: 'default',
  i18n: (key, value) => i18n.t(key, value)
})

import VScaleScreen from 'v-scale-screen'
Vue.use(VScaleScreen)
// 挂载全局
Vue.prototype.$http = http
Vue.prototype.$hasPermission = hasPermission
Vue.prototype.$isMobile = isMobile
Vue.prototype.$isIdCard = isIdCard
Vue.prototype.$getDictLabel = getDictLabel
Vue.prototype.$formValidate = formValidate
Vue.prototype.$CryptoJS =CryptoJS

// 保存整站vuex本地储存初始状态
window.SITE_CONFIG['storeState'] = cloneDeep(store.state)

Date.prototype.Format =  function (fmt) {
  var o = {
     "M+":  this.getMonth() + 1,  // 月份 
     "d+":  this.getDate(),  // 日 
     "h+":  this.getHours(),  // 小时 
     "m+":  this.getMinutes(),  // 分 
     "s+":  this.getSeconds(),  // 秒 
     "q+": Math.floor(( this.getMonth() + 3) / 3),  // 季度 
     "S":  this.getMilliseconds()  // 毫秒 
 };
  if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, ( this.getFullYear() + "").substr(4 - RegExp.$1.length));
  for ( var k  in o)
  if ( new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  return fmt;
}

new Vue({
  i18n,
  router,
  store,
  render: h => h(App)
}).$mount('#app')
// 添加防止缩放代码
window.addEventListener("wheel", function (event) {
  if (event.ctrlKey === true || event.metaKey) {
    event.preventDefault();
  }
}, { passive: false });
